#! /usr/bin/perl -w

## 用管道实现如果标准输出，标准错误不是一个tty设备时
## 把ANSI转义字符删除

use strict;
use Term::ANSIColor qw(:constants);

$Term::ANSIColor::AUTORESET = 1;

unless ( -t STDOUT ) {
    open(STDOUT, "| perl -pe \'s/\\[\\d+m//g\'")
        or die qq{Can not reopen STDOUT};
    open(STDERR, ">&STDOUT");
}

print GREEN "GREEN", RED "RED" , BLUE "BLUE\n";
